#!/usr/bin/perl

use lib::abs qw( .. ../../base_lib );
use JIP::ToolSet;

use English qw( -no_match_vars );
use Test::More tests => 10;
use Config;

BEGIN { use_ok('Net::FastScan'); }
require_ok('Net::FastScan');

can_ok( 'Net::FastScan', qw( new init getActiveFTPServers _maxThreads _worker ) );

defined $Config{'useithreads'} ?
    pass('we have threads') :
        fail('recompile Perl with threads to run this program');

{
    my $scanner = Net::FastScan->new( max_threads => 5 );

    isa_ok( $scanner, 'Net::FastScan' );
    isa_ok( $scanner, 'Class::Base' );
    isa_ok( $scanner, 'Class::Accessor::Fast' );

    is( $scanner->_maxThreads, 5, '_maxThreads accessor' );

    try {
        $scanner->_maxThreads = 'tratata';
    }
    catch {
        like(
            $ARG,
            qr/^Can't modify non-lvalue subroutine call at/,
            'r.o. access to _maxThreads'
        );
    };
}

{
    try {
        Net::FastScan->new( max_threads => '' );
    }
    catch {
        like(
            $ARG,
            qr/^required parameter "max_threads" not defined at/,
            'new() - required parameter "max_threads"'
        );
    };
}
